package classrecord.classes.business;

import classrecord.classes.database.studentemailaddresstbl.STUDENTEMAILADDRESSTBLDomain;
import classrecord.classes.database.studenthomeaddresstbl.STUDENTHOMEADDRESSTBLDomain;
import classrecord.classes.database.studentmobilephonenumbertbl.STUDENTMOBILEPHONENUMBERTBLDomain;
import classrecord.classes.database.studentnametbl.STUDENTNAMETBLDomain;
import classrecord.classes.database.studentnumbertbl.STUDENTNUMBERTBLDomain;
import classrecord.classes.database.studenttelephonenumbertbl.STUDENTTELEPHONENUMBERTBLDomain;
import classrecord.classes.model.College;
import classrecord.classes.model.Course;
import classrecord.classes.model.CurriculumYear;
import classrecord.classes.model.EmailAddress;
import classrecord.classes.model.HomeAddress;
import classrecord.classes.model.IdNumber;
import classrecord.classes.model.MobilePhoneNumber;
import classrecord.classes.model.Name;
import classrecord.classes.model.StudentNumber;
import classrecord.classes.model.TelephoneNumber;
import classrecord.classes.model.University;

public class StudentCredentialsService {

	private StudentCredentials studentCredentials;

	private Name name;
	private StudentNumber studentNumber;
	private IdNumber idNumber;
	private University university;
	private College college;
	private Course course;
	private CurriculumYear curriculumYear;
	private HomeAddress homeAddress;
	private EmailAddress emailAddress;
	private TelephoneNumber telephoneNumber;
	private MobilePhoneNumber mobilePhoneNumber;

	public StudentCredentials getStudentCredentials() {
		return studentCredentials;
	}

	public void setStudentCredentials(StudentCredentials studentCredentials) {
		this.name = studentCredentials.getName();
		this.studentNumber = studentCredentials.getStudentNumber();
		this.idNumber = studentCredentials.getIdNumber();
		this.university = studentCredentials.getUniversity();
		this.college = studentCredentials.getCollege();
		this.course = studentCredentials.getCourse();
		this.curriculumYear = studentCredentials.getCurriculumYear();
		this.homeAddress = studentCredentials.getContactDetails().getHomeAddress();
		this.emailAddress = studentCredentials.getContactDetails().getEmailAddress();
		this.telephoneNumber = studentCredentials.getContactDetails().getTelephoneNumber();
		this.mobilePhoneNumber = studentCredentials.getContactDetails().getMobilePhoneNumber();
	}

	public boolean add() {
		boolean wasInserted = false;
		
		StudentCredentialsDao studentCredentialsDao = new StudentCredentialsDao();
		
		String strStudentNumber = studentNumber.getStudentNumber();
		
		STUDENTNUMBERTBLDomain studentnumbertblDomain = new STUDENTNUMBERTBLDomain();
		studentnumbertblDomain.setStudentNumber(strStudentNumber);
		studentCredentialsDao.setStudentnumbertblDomain(studentnumbertblDomain);
		
		String strLastName = name.getLastName();
		String strGivenName = name.getGivenName();
		String strMiddleName = name.getMiddleName();
		String strMiddleInitial = name.getMiddleInitial();
		String strNameExtension = name.getNameExtension();		
		
		STUDENTNAMETBLDomain studentnametblDomain = new STUDENTNAMETBLDomain();
		studentnametblDomain.setStudentNumber(strStudentNumber);
		studentnametblDomain.setLastName(strLastName);
		studentnametblDomain.setGivenName(strGivenName);
		studentnametblDomain.setMiddleName(strMiddleName);
		studentnametblDomain.setMiddleInitial(strMiddleInitial);
		studentnametblDomain.setNameExtension(strNameExtension);
		studentCredentialsDao.setStudentnametblDomain(studentnametblDomain);
		
		
		/*
		 * [Note]: No related objects for IdNumber, University, College, Course,
		 * CurriculumYear.
		 * TODO: Create related objects (Column, DAO, and Domain class and 
		 * related table scripts.
		 */

		
		String strHomeAddress = homeAddress.getHomeAddress();
		
		STUDENTHOMEADDRESSTBLDomain studenthomeaddresstblDomain = new STUDENTHOMEADDRESSTBLDomain();
		studenthomeaddresstblDomain.setStudentNumber(strStudentNumber);
		studenthomeaddresstblDomain.setHomeAddress(strHomeAddress);		
		studentCredentialsDao.setStudenthomeaddresstblDomain(studenthomeaddresstblDomain);
		
		
		String strEmailAddress = emailAddress.getEmailAddress();
		
		STUDENTEMAILADDRESSTBLDomain studentemailaddresstblDomain = new STUDENTEMAILADDRESSTBLDomain();
		studentemailaddresstblDomain.setStudentNumber(strStudentNumber);
		studentemailaddresstblDomain.setEmailAddress(strEmailAddress);
		studentCredentialsDao.setStudentemailaddresstblDomain(studentemailaddresstblDomain);
		
		
		String strTelephoneNumber = telephoneNumber.getTelephoneNumber();
		
		STUDENTTELEPHONENUMBERTBLDomain studenttelephonenumbertblDomain = new STUDENTTELEPHONENUMBERTBLDomain();
		studenttelephonenumbertblDomain.setStudentNumber(strStudentNumber);
		studenttelephonenumbertblDomain.setTelephoneNumber(strTelephoneNumber);
		studentCredentialsDao.setStudenttelephonenumbertblDomain(studenttelephonenumbertblDomain);
		
		
		String strMobilePhoneNumber = mobilePhoneNumber.getMobilePhoneNumber();
		
		STUDENTMOBILEPHONENUMBERTBLDomain studentmobilephonenumbertblDomain = new STUDENTMOBILEPHONENUMBERTBLDomain();
		studentmobilephonenumbertblDomain.setStudentNumber(strStudentNumber);
		studentmobilephonenumbertblDomain.setMobilePhoneNumber(strMobilePhoneNumber);
		studentCredentialsDao.setStudentmobilephonenumbertblDomain(studentmobilephonenumbertblDomain);
		
		
		wasInserted = studentCredentialsDao.add();
		
		return wasInserted;
	}

	public boolean update() {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean physicalDelete() {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean logicalDelete() {
		// TODO Auto-generated method stub
		return false;
	}

	public STUDENTNUMBERTBLDomain logicalRetrieve() {
		// TODO Auto-generated method stub
		return null;
	}

	public STUDENTNUMBERTBLDomain physicalRetrieve() {
		// TODO Auto-generated method stub
		return null;
	}

	public int getPhysicalRecordCount() {
		// TODO Auto-generated method stub
		return 0;
	}

	public int getLogicalRecordCount() {
		// TODO Auto-generated method stub
		return 0;
	}

}
